from django.contrib import admin

from .models import Uslugi, Ztarifs

# Register your models here.
# admin.site.disable_action("delete_selected")


@admin.register(Uslugi)
class UslugiAdmin(admin.ModelAdmin):
    list_display = (
        "usl",
        "kusl",
        "ok_isl_p",
        "nusl",
        "vt",
        # "opl",
        "uet",
        "trf",
        "isp",
        "dnu",
        "dku",
    )
    list_display_links = ("usl",)
    search_fields = ("kusl", "nusl")
    list_filter = ("isp", "vt")
    list_per_page = 50

    actions = ("is_vt", "is_unvt")

    @admin.action(description="Отметка ВТ")
    def is_vt(self, request, queryset) -> None:  # noqa: ARG002
        queryset.update(vt=True)

    @admin.action(description="Отметка ВТ Убрать")
    def is_unvt(self, request, queryset) -> None:  # noqa: ARG002
        queryset.update(vt=False)

    # actions = ("delete_selected",)


@admin.register(Ztarifs)
class ZtarifsAdmin(admin.ModelAdmin):
    list_display = ("usl", "sdl", "trf_zp", "dn", "dk", "type_usl")
    list_display_links = ("usl",)
    search_fields = ("usl__kusl", "sdl__sdl")
    list_filter = ("type_usl",)
    list_per_page = 50
